/*
 * UserAddress.java
 * business
 *
 * Created by ChenTao on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.data.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

/** 服务器返回的用户送货地址 */
public class UserAddress implements Parcelable {

    /** 地址列表中是否默认选择该地址 */
    private boolean isSelected;
    /** 是否是默认地址 */
    private boolean isDefault;
    @SerializedName("address_id")
    private String addressId;
    @SerializedName("consignee")
    private String consignee;
    @SerializedName("country")
    private String country;
    @SerializedName("address")
    private String address;
    /** 格式化后的手机号码 133****3333 */
    @SerializedName("tel")
    private String tel;
    @SerializedName("province_id")
    private String provinceId;
    @SerializedName("city_id")
    private String cityId;
    @SerializedName("area_id")
    private String areaId;
    /** 真实手机号码 13333333333 */
    @SerializedName("mobile")
    private String mobile;
    @SerializedName("province")
    private String province;
    @SerializedName("city")
    private String city;
    @SerializedName("district")
    private String district;

    public UserAddress() {
    }

    protected UserAddress(Parcel in) {
        this.isSelected = in.readByte() != 0;
        this.isDefault = in.readByte() != 0;
        this.addressId = in.readString();
        this.consignee = in.readString();
        this.country = in.readString();
        this.address = in.readString();
        this.tel = in.readString();
        this.provinceId = in.readString();
        this.cityId = in.readString();
        this.areaId = in.readString();
        this.mobile = in.readString();
        this.province = in.readString();
        this.city = in.readString();
        this.district = in.readString();
    }

    public static final Parcelable.Creator<UserAddress> CREATOR =
            new Parcelable.Creator<UserAddress>() {
                @Override
                public UserAddress createFromParcel(Parcel source) {
                    return new UserAddress(source);
                }

                @Override
                public UserAddress[] newArray(int size) {
                    return new UserAddress[size];
                }
            };

    public boolean isDefault() {
        return isDefault;
    }

    public void setDefault(boolean aDefault) {
        isDefault = aDefault;
    }

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    public String getAddressId() {
        return addressId;
    }

    public void setAddressId(String addressId) {
        this.addressId = addressId;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(String provinceId) {
        this.provinceId = provinceId;
    }

    public String getCityId() {
        return cityId;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public String getAreaId() {
        return areaId;
    }

    public void setAreaId(String areaId) {
        this.areaId = areaId;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isDefault ? (byte) 1 : (byte) 0);
        dest.writeString(this.addressId);
        dest.writeString(this.consignee);
        dest.writeString(this.country);
        dest.writeString(this.address);
        dest.writeString(this.tel);
        dest.writeString(this.provinceId);
        dest.writeString(this.cityId);
        dest.writeString(this.areaId);
        dest.writeString(this.mobile);
        dest.writeString(this.province);
        dest.writeString(this.city);
        dest.writeString(this.district);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserAddress that = (UserAddress) o;

        return addressId.equals(that.addressId);
    }

    @Override
    public int hashCode() {
        return addressId.hashCode();
    }
}
